from Crypto.Util.number import *
from gmpy2 import *
from secret import flag1, flag2

m1 = bytes_to_long(flag1)
m2 = bytes_to_long(flag2)


# lcg加密
def crypto1():
    length = m1.bit_length()
    a = getPrime(length)
    b = getPrime(length)
    m = getPrime(length)
    seed = m1
    output = []
    for i in range(10):
        seed = (a * seed + b) % m
        output.append(seed)
    print('output =', output)


def crypto2():
    m2_list = [3, 7 ** 2, 13, 79, 409, 572360576146727, 33065072795963938522763]
    p = getPrime(1024)
    q = getPrime(1024)
    n = p * q
    e = 65537
    hint = powmod(2024 * q + 114514, p, n)
    c = []
    for i in range(len(m2_list)):
        c.append(int(powmod(m2_list[i], e, n)))
    print('c =', c)
    print('hint =', hint)
    print('nn =', n)


if __name__ == "__main__":
    crypto1()
    crypto2()
